package com.niit.main;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.niit.entity.Student;
import com.niit.mapper.StudentMapper;
import com.niit.util.MybatisUtil;

/**
 ** 根据任意列关键字查询学生列表 <br>
 * 模糊查询：根据任意指定的列，查询包含指定关键字的学生列表，如可以根据学号、姓名、班级等任意一列进行关键字查询
 *
 * @author hanliang
 */
public class Test09_getStudentbyKeywords {

	public static void main(String[] args) {

		List<Student> list = null;
		// sname 文
		// sid 444
		// sbatch 02

		try (SqlSession session = MybatisUtil.openSession()) {
			StudentMapper mapper = session.getMapper(StudentMapper.class);
			list = mapper.getStudentListByKeyword("sid", "444");
//			list = mapper.getStudentListByKeyword("sname","文");
//			list = mapper.getStudentListByKeyword("sbatch", "01");
		}

		System.out
				.println("-------------------------------------------------------------------------------------------");
		System.out.println("学号\t\t姓名\t\t密码\t\t性别\t班级");
		System.out
				.println("-------------------------------------------------------------------------------------------");

		for (Student s : list) {
			System.out.println(s);
		}
	}
}
